<template>
  <view>
    <nav-bar title="修改电话号码"></nav-bar>
    <view class="contain">
      <u--form labelPosition="left" :model="model1" :rules="rules" ref="uForm">
        <u-form-item label="电话号码" prop="userInfo.phoneNumber" borderBottom ref="item1" labelWidth="80" >
          <u--input v-model="model1.userInfo.phoneNumber" border="none" type="number"></u--input>

        </u-form-item>
        <view class="title">请输入电话号码</view>
      </u--form>
      <view class="button" @click="submit">保存</view>

    </view>
  </view>
</template>

<script>
import NavBar from '@/components/nav-bar/index.vue'
import tabIndex from '../../components/statis/tab-index.vue'
import { getToken } from "@/utils/auth"
import { getUserData,editUserData } from '@/api/system/mine'
export default {
  name: 'uploadPhoto',
  components: { NavBar, tabIndex },
  data() {
    return {
      mainHeight: '',
      model1: {
        userInfo: {
          phoneNumber: '',
        },
      },
      userData:{}
    }
  },
  created() {
    this.mainHeight = this.$store.getters.heightData.noTabMainHeight + 'px'
    this.userId = uni.getStorageSync('userId')
    this.getUserData()
  },
  methods: {
    getUserData() {
      getUserData({ userId: this.userId }).then((res) => {
        this.model1.userInfo.phoneNumber = res.data.phoneNumber
        this.userData = res.data
      })
    },
    submit() {
      const params = {
        id: this.userData.id,
        phoneNumber: this.model1.userInfo.phoneNumber
      }
      editUserData(params).then((res) => {
        if (res.code === 200) {
          uni.redirectTo({
            url: '/subPages/mine/myMessage',
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.contain {
  height: 100%;
  width: 100%;
  background-color: #fff;
  padding: 40rpx 20rpx 60rpx;

  .title {
    font-size: 28rpx;
    font-weight: 400;
    color: rgba(166, 166, 166, 1);
    margin-top: 10rpx;
  }

  .button {
    width: 100%;
    height: 80rpx;
    opacity: 1;
    border-radius: 46rpx;
    background: rgba(194, 126, 21, 1);
    text-align: center;
    line-height: 80rpx;
    margin-top: 160%;
    font-size: 40rpx;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);

  }
}
</style>